package com.sg.file.transform.provider.event;

import com.sg.file.transform.api.dto.TransformReqeust;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * 异步转换事件发布
 * Created by asus on 2018/7/20.
 */
@Component
public class AsynTransformPublisher {

    @Autowired
    private ApplicationContext context;

    /**
     * 通过spring 上下文将异步文件转换请求发布
     * @param transformReqeust
     */
    public void publish(TransformReqeust transformReqeust){
        AsynFileTransformEvent asynFileTransformEvent =
                new AsynFileTransformEvent(this,transformReqeust);
        context.publishEvent(asynFileTransformEvent);
    }

    /**
     * 通过spring 上下文将异步文件转换请求发布
     * @param transformReqeusts
     */
    public void publish(TransformReqeust[] transformReqeusts){
        AsynFileTransformEvent asynFileTransformEvent =
                new AsynFileTransformEvent(this,transformReqeusts);
        context.publishEvent(asynFileTransformEvent);
    }
}
